{include file="public/_meta" /}
<body>
<style>
    .required_b{
        color: red;
    }
</style>
<div class="wrapper">

    {include file="public/_header" /}

    <!-- Sidebar -->
    {include file="public/_menu" /}
    <!-- End Sidebar -->

    <div class="main-panel">

        <div class="content">
            <div class="page-inner">

                <!-- 面包屑 -->
                {include file="public/_page_header" /}

                <div class="row">
                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <div class="d-flex align-items-center">
                                    <h4 class="card-title">线索分发记录</h4>
                                    <!--<button class="btn btn-primary btn-round ml-auto" data-toggle="modal" data-target="#addRowModal" onClick="add_item(0)">
                                        <i class="fa fa-plus"></i>
                                        添加
                                    </button>-->
                                </div>

                                <form class="row">

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="clue_id" value="{$clue_id}" placeholder="线索ID">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="clue_name" value="{$clue_name}" placeholder="线索名称">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="phone" value="{$phone}" placeholder="电话">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="mer_name" value="{$mer_name}" placeholder="商户名称">
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="ac_name" value="{$ac_name}" placeholder="账户名称">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="adv_id" value="{$adv_id}" placeholder="账户ID">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">

                                            <select class="form-control input-full" name="pro_id" id="pro_id">
                                                <option value="">全部产品</option>
                                                {volist name="products" id="vo"}
                                                <option value="{$key}">{$vo}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">

                                            <select class="form-control input-full" name="sprovince" id="sprovince" onchange="loadRegion('sprovince',2,'scity')">
                                                <option value="0">省份/直辖市</option>
                                                {volist name="province" id="vo"}
                                                <option value="{$vo.id}" >{$vo.name}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">

                                            <select class="form-control input-full" name="scity" id="scity">
                                                <option value="0">市/县</option>
                                            </select>
                                        </div>
                                    </div>


                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <input type="text" class="form-control" name="times" id="times" value="{$times}" placeholder="创建时间" autocomplete="off">
                                        </div>
                                    </div>

                                    <div class="col-md-6 col-lg-2">
                                        <div class="form-group">
                                            <button type="submit" class="btn btn-primary">查询</button>
                                            <a href="{:url('ClueLog/index')}" class="btn btn-info" style="color: white;position: absolute;left: 110px;">重置</a>
                                        </div>
                                    </div>

                                </form>

                            </div>


                            <div class="card-body">

                                <div class="table-responsive">
                                    <table id="add-row" class="display table table-striped table-hover" >
                                        <thead>
                                        <tr>
                                            <th>ID</th>
                                            <th>渠道</th>


                                            <th>线索账户</th>

                                            <th>推送商户</th>
                                            <th>线索信息</th>
                                            <!--                                            <th>线索序号</th>-->
                                           <!-- <th>线索名称</th>
                                            <th>电话</th>-->
                                            <th>所属城市</th>
                                            <th>推送产品</th>
                                            <th>收费方式</th>
<!--                                            <th>金额</th>-->
                                            <th>跟进记录</th>

                                            <th>推送时间</th>
                                            {if condition="!in_array($group_id,[4,5])"}
                                            <!--<th style="width: 10%">操作</th>-->
                                            {/if}
                                        </tr>
                                        </thead>

                                        <tbody>

                                        {volist name="infos" id="vo"}
                                        <tr>
                                            <td>{$vo.id}</td>
                                            <td>{$vo.channel_name}</td>

                                            <td>
                                                账户ID：【{$vo.adv_id}】<br>
                                                名称：{$vo.acc_name}<br>
                                                简称：{$vo.acc_desc}
                                            </td>

                                            <td>
                                                账号：{$vo.username}<br>
                                                手机：{$vo.mer_phone}<br>
                                                商户名：{$vo.mer_name}
                                            </td>
                                            <td>
                                                线索名称：{$vo.clue_name}<br>
                                                {if condition="!in_array($group_id,[4,5])"}
                                                线索电话：{$vo.phone}<br>
                                                {else /}
                                                线索电话：{$vo.telephone}<br>
                                                {/if}

                                                线索ID：{$vo.ad_clue_id}<br>
                                                {volist name="vo['remark_data']" id="vv"}
                                                <span>{$vv}</span><br>
                                                {/volist}
                                            </td>
                                           <!-- <td>{$vo.clue_name}</td>
                                            <td>{$vo.phone}</td>-->
                                            <td>线索城市：{$vo.city}<br>
                                                商户显示：{$vo.show_city}
                                            </td>
                                            <td>{$vo.pro_name}</td>
                                            <td>{$vo.charge_type}<br>{$vo.price}</td>
<!--                                            <td>{$vo.price}</td>-->
                                            <td>
                                                {volist name="vo['progress']" id="item"}
                                                <p>
                                                <span>{$item.create_time}：</span>
                                                <span>{$item.content}</span>
                                                </p>
                                                {/volist}
                                            </td>
                                            <td>{$vo.create_time}</td>
                                            {if condition="!in_array($group_id,[4,5])"}
                                            <!--<td>
                                                <div class="form-button-action">

                                                    <button type="button" data-toggle="tooltip" onClick="admin_del(this,'{$vo.id}')" title="" class="layui-btn layui-btn-danger layui-btn-sm" data-original-title="直接删除">
                                                        <i class="layui-icon"></i>直接删除
                                                    </button>
                                                    <button type="button" class="layui-btn layui-btn-primary layui-border-red layui-btn-sm" onClick="admin_del2(this,'{$vo.id}')"> 退款删除</button>
                                                </div>



                                            </td>-->
                                            {/if}
                                        </tr>
                                        {/volist}

                                        </tbody>
                                    </table>

                                    <!-- 分页 (调取通用方法)-->
                                     <div class="layui-box layui-laypage layui-laypage-molv">{:pagination($infos)}</div>

                                </div>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
        </div>

        {include file="public/_footer" /}


    </div>



</div>

{include file="public/_js" /}

</body>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">
    laydate.render({
        elem: '#times'
        ,type: 'datetime'
        ,range: true
    });

    var SCOPE = {
        'status_url':"{:url('clue/status')}",
        'delete_url':"{:url('clue/delete')}",
        'item_url':"{:url('clue/edit')}",
        'item_url2':"{:url('clue/edit2')}",
        'add_url':"{:url('clue/save')}",
        'clue_url':"{:url('clue/clue_url')}",
        'city_url':"{:url('clue/getRegion')}",
        'push_rule':"{:url('clue/getMerchantPush')}",
        'push_url':"{:url('clue/findPush')}",
        'get_account':"{:url('stat/getAccount')}",
        'saveclue':"{:url('stat/saveClueCost')}",
        'editclue':"{:url('stat/editClueCost')}",
        'del_clue':"{:url('stat/delClueCost')}",
        'improtexcel':"{:url('stat/importClueCost')}",
    };

    function loadRegion(sel,type_id,selName){
        $("#"+selName+" option").each(function(){
            $(this).remove();
        });
        $("<option value=0>请选择</option>").appendTo($("#"+selName));
        if($("#"+sel).val()==0){
            return;
        }
        $.post(SCOPE.city_url,{pid:$("#"+sel).val(),type:type_id},
            function(data){
                if(data.code == 1001){
                    $.each(data.data,function(idx,item){
                        $("<option value="+item.id+">"+item.name+"</option>").appendTo($("#"+selName));
                    });
                }else{
                    $("<option value='0'>请选择</option>").appendTo($("#"+selName));
                }
            }
        );
    }

    // $('#sprovince').find('option[value="{$sprovince}"]').attr('selected',true);
    $('#sprovince').val('{$sprovince}');
    var sprovinceid=$('#sprovince').val();
    if(sprovinceid>0){
        $.post(SCOPE.city_url,{pid:sprovinceid,type:2},
            function(data){
                if(data.code == 1001){
                    $.each(data.data,function(idx,item){
                        $("<option value="+item.id+">"+item.name+"</option>").appendTo($("#scity"));
                    });

                    // $('#scity').find('option[value="{$scity}"]').attr('selected',true);
                    $('#scity').val('{$scity}');

                }else{
                    $("<option value='0'>请选择</option>").appendTo($("#scity"));
                }
            }
        );
    }

    /*删除*/
    function admin_del(obj,id){
        layer.confirm('确认要直接删除,不退款吗？',function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('ClueLog/delete')}",
                dataType: 'json',
                data: {id:id},
                success: function(data){
                    if(data.code == 1001){
                        $(obj).parents("tr").remove();
                        layer.msg('删除成功!',{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }

    /*删除*/
    function admin_del2(obj,id){
        layer.confirm('确认要删除并且退款吗？',function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('ClueLog/delete2')}",
                dataType: 'json',
                data: {id:id,refund:1},
                success: function(data){
                    if(data.code == 1001){
                        $(obj).parents("tr").remove();
                        layer.msg('删除成功!',{icon:1,time:2000});
                    }else{
                        layer.msg(data.msg,{icon:2,time:2000});
                    }

                },
                error:function(data) {
                    layer.msg('网络错误,稍后再试...',{icon:2,time:2000});
                }
            });
        });
    }

    // $('#pro_id').find('option[value="{$pro_id}"]').attr('selected',true);
    $('#pro_id').val('{$pro_id}');

</script>
</html>




























